package com.ml.mall.api.sys;

import com.ml.mall.bean.base.ApiRestResult;
import com.ml.mall.bean.page.Page;
import com.ml.mall.bean.req.sys.SysRoutingQueryPageDto;
import com.ml.mall.entity.sys.SysRouting;
import com.ml.mall.enums.CommonEnum;
import com.ml.mall.exception.BizException;
import com.ml.mall.service.sys.SysRoutingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @description description
 * @author yx
 * @date 2021/9/28
 * @version 1.0
*/
@Api(tags = "【auth】路由接口")
@RequestMapping("/routing")
@RestController
public class SysRoutingController {
    @Autowired
    private SysRoutingService sysRoutingService;

    @ApiOperation("分页查询路由")
    @PostMapping("/query_page")
    public ApiRestResult routingQueryPage(@RequestBody @Valid SysRoutingQueryPageDto dto){
        Page<SysRouting> result = sysRoutingService.routingQueryPage(dto);
        if(null == result){
            throw new BizException(CommonEnum.SELECT_ERROR);
        }
        return ApiRestResult.ok(result);
    }
}
